/* 

Paper: Gentrification and pioneer businesses 
Authors: Behrens, Boulam, Martin, Mayneris 

Name dofile: table4.do  
Version: 16 nov. 2021 

Output: Table 4

Inputs:

- predict_gentri_database (from creation_db_table4.do)
*/ 


use predict_gentri_database, clear 

global instruct "tdec(3) rdec(3) auto(3) bdec (3) symbol($^a$,$^b$,$^c$)  se e(r2_p) label nocons"

local var_demo_housing500 lpc_income500  sh_edu500 lcrent age_build500 sh_black500 sh_asian500 sh_other500 lpop500
local var_amenity500 waterfront lnum_train_lines500 lnum_bus_lines500 ldis_parks lpointlm_count500
local var_rc500 lcount_rc_A_NW500 sh_vacant500 ltdheight500 histdist500
local var_crime500 murder500  burglary500 robbery500 rape500
local cut "0.5"

***********
*500m - OLS
***********

local var_contag500 l_gentri_0010500

acreg gentri_0010 dplants_pion500 dlplants_npion500 `var_demo_housing500' `var_amenity500 ' `var_contag500' if t==2&poor_0010==1, latitude(intptlat) longitude(intptlon) distcutoff(`cut') time(t) id(id_conc)  lag(0) spatial hac
outreg2 using "table4_500_ols.xls", ctitle(`v')  $instruct  replace

acreg gentri_0010 dplants_pion500 dlplants_npion500  `var_demo_housing500' `var_amenity500' `var_contag500' `var_crime500' `var_rc500'  if t==2&poor_0010==1, latitude(intptlat) longitude(intptlon) distcutoff(`cut') time(t) id(id_conc)  lag(0) spatial hac
outreg2 using "table4_500_ols.xls", ctitle(`v')  $instruct  append

foreach v in "dlpc_inc" "dsh_edu" {

local var_contag500 l_`v'500

acreg `v' dplants_pion500 dlplants_npion500 `var_demo_housing500' `var_amenity500' `var_contag500' if t==2&poor_0010==1, latitude(intptlat) longitude(intptlon) distcutoff(`cut') time(t) id(id_conc)  lag(0) spatial hac
outreg2 using "table4_500_ols.xls", ctitle(`v')  $instruct  append

acreg `v' dplants_pion500 dlplants_npion500  `var_demo_housing500' `var_amenity500' `var_contag500' `var_crime500' `var_rc500'  if t==2&poor_0010==1, latitude(intptlat) longitude(intptlon) distcutoff(`cut') time(t) id(id_conc)  lag(0) spatial hac
outreg2 using "table4_500_ols.xls", ctitle(`v')  $instruct  append

}

**********
*500m - IV
**********

local var_contag500 l_gentri_0010500

acreg gentri_0010  `var_demo_housing500' `var_amenity500'  `var_contag500' dlplants_npion500 (dplants_pion500=dplants_pion_instr500) if t==2&poor_0010==1, latitude(intptlat) longitude(intptlon) distcutoff(`cut') time(t) id(id_conc) lag(0) spatial hac
outreg2 using "table4_500_iv.xls", ctitle(`v')  $instruct  replace

acreg gentri_0010  `var_demo_housing500' `var_amenity500' `var_contag500' `var_crime500' `var_rc500'  dlplants_npion500  (dplants_pion500=dplants_pion_instr500) if t==2&poor_0010==1, latitude(intptlat) longitude(intptlon) distcutoff(`cut') time(t) id(id_conc)  lag(0) spatial hac
outreg2 using "table4_500_iv.xls", ctitle(`v')  $instruct  append


foreach v in "dlpc_inc" "dsh_edu" {

local var_contag500 l_`v'500

acreg `v'  `var_demo_housing500' `var_amenity500'  `var_contag500' dlplants_npion500 (dplants_pion500=dplants_pion_instr500) if t==2&poor_0010==1, latitude(intptlat) longitude(intptlon) distcutoff(`cut') time(t) id(id_conc) lag(0) spatial hac
outreg2 using "table4_500_iv.xls", ctitle(`v')  $instruct  append

acreg `v'  `var_demo_housing500' `var_amenity500' `var_contag500' `var_crime500' `var_rc500'  dlplants_npion500  (dplants_pion500=dplants_pion_instr500) if t==2&poor_0010==1, latitude(intptlat) longitude(intptlon) distcutoff(`cut') time(t) id(id_conc)  lag(0) spatial hac
outreg2 using "table4_500_iv.xls", ctitle(`v')  $instruct  append

}

***********
*250m - OLS
***********

global instruct "tdec(3) rdec(3) auto(3) bdec (3) symbol($^a$,$^b$,$^c$)  se e(r2_p) label nocons"

local var_demo_housing250 lpc_income250  sh_edu250 lcrent age_build250 sh_black250 sh_asian250 sh_other250 lpop250
local var_amenity250 waterfront lnum_train_lines250 lnum_bus_lines250 ldis_parks lpointlm_count250
local var_rc250 lcount_rc_A_NW250 sh_vacant250 ltdheight250 histdist250
local var_crime250 murder250  burglary250 robbery250 rape250
local cut "0.5"

local var_contag250 l_gentri_0010250

acreg gentri_0010 dplants_pion250 dlplants_npion250 `var_demo_housing250' `var_amenity250 ' `var_contag250' if t==2&poor_0010==1, latitude(intptlat) longitude(intptlon) distcutoff(`cut') time(t) id(id_conc)  lag(0) spatial hac
outreg2 using "table4_250_ols.xls", ctitle(`v')  $instruct  replace

acreg gentri_0010 dplants_pion250 dlplants_npion250  `var_demo_housing250' `var_amenity250' `var_contag250' `var_crime250' `var_rc250'  if t==2&poor_0010==1, latitude(intptlat) longitude(intptlon) distcutoff(`cut') time(t) id(id_conc)  lag(0) spatial hac
outreg2 using "table4_250_ols.xls", ctitle(`v')  $instruct  append

foreach v in "dlpc_inc" "dsh_edu" {

local var_contag250 l_`v'250

acreg `v' dplants_pion250 dlplants_npion250 `var_demo_housing250' `var_amenity250 ' `var_contag250' if t==2&poor_0010==1, latitude(intptlat) longitude(intptlon) distcutoff(`cut') time(t) id(id_conc)  lag(0) spatial hac
outreg2 using "table4_250_ols.xls", ctitle(`v')  $instruct  append

acreg `v' dplants_pion250 dlplants_npion250  `var_demo_housing250' `var_amenity250' `var_contag250' `var_crime250' `var_rc250'  if t==2&poor_0010==1, latitude(intptlat) longitude(intptlon) distcutoff(`cut') time(t) id(id_conc)  lag(0) spatial hac
outreg2 using "table4_250_ols.xls", ctitle(`v')  $instruct  append

}

*************
*Contig - OLS
*************

global instruct "tdec(3) rdec(3) auto(3) bdec (3) symbol($^a$,$^b$,$^c$)  se e(r2_p) label nocons"

local var_demo_housingcont lpc_incomecont  sh_educont lcrent age_buildcont sh_blackcont sh_asiancont sh_othercont lpopcont
local var_amenitycont waterfront lnum_train_linescont lnum_bus_linescont ldis_parks lpointlm_countcont
local var_rccont lcount_rc_A_NWcont sh_vacantcont ltdheightcont histdistcont
local var_crimecont murdercont  burglarycont robberycont rapecont
local cut "0.5"

local var_contagcont l_gentri_0010con

acreg gentri_0010 dplants_pioncon dlplants_npioncon `var_demo_housingcont' `var_amenitycont ' `var_contagcont' if t==2&poor_0010==1, latitude(intptlat) longitude(intptlon) distcutoff(`cut') time(t) id(id_conc)  lag(0) spatial hac
outreg2 using "table4_cont_ols.xls", ctitle(`v')  $instruct  replace

acreg gentri_0010 dplants_pioncon dlplants_npioncon  `var_demo_housingcont' `var_amenitycont' `var_contagcont' `var_crimecont' `var_rccont'  if t==2&poor_0010==1, latitude(intptlat) longitude(intptlon) distcutoff(`cut') time(t) id(id_conc)  lag(0) spatial hac
outreg2 using "table4_cont_ols.xls", ctitle(`v')  $instruct  append

foreach v in "dlpc_inc" "dsh_edu" {

local var_contagcont l_`v'con

acreg `v' dplants_pioncon dlplants_npioncon `var_demo_housingcont' `var_amenitycont ' `var_contagcont' if t==2&poor_0010==1, latitude(intptlat) longitude(intptlon) distcutoff(`cut') time(t) id(id_conc)  lag(0) spatial hac
outreg2 using "table4_cont_ols.xls", ctitle(`v')  $instruct  append

acreg `v' dplants_pioncon dlplants_npioncon  `var_demo_housingcont' `var_amenitycont' `var_contagcont' `var_crimecont' `var_rccont'  if t==2&poor_0010==1, latitude(intptlat) longitude(intptlon) distcutoff(`cut') time(t) id(id_conc)  lag(0) spatial hac
outreg2 using "table4_cont_ols.xls", ctitle(`v')  $instruct  append

}